package cn.edu.nju.software.cdiy.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import cn.edu.nju.software.cdiy.bean.Scheme;
import cn.edu.nju.software.cdiy.bean.User;
import cn.edu.nju.software.cdiy.bean.Value;
import cn.edu.nju.software.cdiy.dao.SchemeDao;
import cn.edu.nju.software.cdiy.dao.UserDao;
import cn.edu.nju.software.cdiy.dao.ValueDao;
import cn.edu.nju.software.cdiy.service.UserService;
import cn.edu.nju.software.cdiy.util.BusinessConstant;

public class UserServiceImpl implements UserService{

	@Autowired
	private UserDao userDao;
	@Autowired
	private SchemeDao schemeDao;
	@Autowired
	private ValueDao valueDao;

	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	public void setSchemeDao(SchemeDao schemeDao) {
		this.schemeDao = schemeDao;
	}

	public void setValueDao(ValueDao valueDao) {
		this.valueDao = valueDao;
	}

	@Override
	public User login(User user) {
		return userDao.login(user);
	}

	@Override
	public User updateUser(User user) {
		return userDao.updateUser(user);
	}

	@Override
	public User registor(User user) {
		return userDao.updateRegistor(user);
	}

	@Override
	public Value getNormal() {
		return valueDao.getValue(BusinessConstant.U_NORMAL);
	}

	@Override
	public Value getActiveState() {
		return valueDao.getValue(BusinessConstant.U_ACTIVE);
	}

	@Override
	public Value getGender(int key) {
		return valueDao.getValue(key);
	}

	@Override
	public User getUserById(long userId) {
		return this.userDao.getUserById(userId);
	}

	@Override
	public List<Scheme> getUserSchemes(Long userId) {
		return schemeDao.loadUserScheme(userId);
	}

}
